<template>
  <van-nav-bar title="标题" />

  <div class="swiper-wrap">
    <van-search
      v-model="value"
      placeholder="请输入搜索关键词"
      background="transparent"
      shape="round"
    />
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="red">
      <van-swipe-item v-for="item in bannerList" :key="item">
        <img :src="item" alt="" />
      </van-swipe-item>
    </van-swipe>
  </div>

  <van-grid>
    <van-grid-item text="文字">
      <template #icon>🏀</template>
    </van-grid-item>
    <van-grid-item icon="photo-o" text="文字" />
    <van-grid-item icon="photo-o" text="文字" />
    <van-grid-item icon="photo-o" text="文字" />
  </van-grid>
</template>

<script lang="ts">
import { defineComponent, ref, onMounted } from "vue";
import { getBannerApi } from "@/utils/api";

export default defineComponent({
  setup() {
    const bannerList = ref<string[]>([]);
    onMounted(async () => {
      const res = await getBannerApi();
      bannerList.value = res.result.list;
    });

    const value = ref<string>("");

    return { bannerList, value };
  },
});
</script>

<style lang="less" scoped>
.swiper-wrap {
  position: relative;
}

.my-swipe {
  height: 250px;

  .van-swipe-item {
    color: #fff;
    height: 250px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

/deep/.van-swipe__indicator {
  width: 30px;
  height: 5px;
  border-radius: 0;
}

.van-search {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9;
  width: 100%;
}
/deep/.van-search__content--round {
  background: rgba(255, 255, 255, 0.6);
}
/deep/.van-field__control::placeholder {
  color: #fff;
}
</style>
